<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('店铺小程序列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="case-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <p style="width: 110px">模板库类型： </p>
                            <select name="templateType" th:with="type=${@dict.getType('applet_template_type')}">
                                <option value="">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var deleteFlag = [[${@permission.hasPermi('back:wechatOpen:deleteTemplate')}]];
    const templateTypeDict = [[${@dict.getType('applet_template_type')}]]
    var prefix = ctx + "back/wechatOpen";

    $(function () {
        var options = {
            url: prefix + "/searchTemplateList",
            removeUrl: prefix + "/deleteTemplate",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "小程序模板库列表",
            height: 600,
            columns: [
                {
                    field: 'templateId',
                    title: '模板ID'
                },
                {
                    field: 'templateType',
                    title: '模板类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(templateTypeDict, value);
                    }
                },
                {
                    field: 'sourceMiniProgramAppid',
                    title: '小程序ID'
                },
                {
                    field: 'sourceMiniProgram',
                    title: '小程序名称'
                },
                {
                    field: 'userVersion',
                    title: '版本号'
                },
                {
                    field: 'userDesc',
                    title: '版本描述'
                },
                {
                    field: 'createTime',
                    title: '加入模板时间',
                    formatter: function(value,row,index){
                        return new Date(value*1000).toLocaleDateString();
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + deleteFlag + '" href="#" onclick="$.operate.remove(\'' + row.templateId + '\')"><i class="fa fa-remove">删除模板</i></a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

</script>
</body>
</html>